<?php

class Coupon extends AppModel {
  public $name = 'Coupon';
  public $belongsTo = array('Company'=>array(
      'className'=> 'Company',
      'foreignKey'=>'company_id',
      'type' =>'inner'
 ));


  public $validate = array(
      'Coupon.title' => array(
          'name' => 'notEmpty',
          'message'=>'Tile is required'
      ),
      'Coupon.description' => array(
          'name' => 'notEmpty',
          'message'=>'Description is required'
      ),
      'Coupon.company_id' => array(
          'name' => 'notEmpty',
          'message'=>'Company is required'
      ),

      'Company.image_path'=>array(
              'rule'=>array('validImageFormat'),
              'message'=>'Specify a valid image (gif, jpg, png)',
              'allowEmpty'=>true,
                'required'=>false
      ),

      'Company.email'=>array(
          'required' => array(
            'rule' => array('email',true),
            'allowEmpty'=> true,
            'required'=>false,
            'message'=>'Specify a valid email address'
          )
      ),
       'start_date' => array(
          'formatRule' => array(
              'rule' => array('validDateFormat'),
              'allowEmpty' => false,
              'message' => 'Enter a valid Start date (mm/dd/yyyy)'
          ),
          'dateRestrictionRule' => array(
              'rule' => array('dateBefore', 'end_date'),
              'message' => 'Start date must be before End date'
      )),
      'end_date' => array(
          'rule' => array('validDateFormat'),
          'allowEmpty' => false,
          'message' => 'Enter a valid End date (mm/dd/yyyy)'
      ),
        'valid_start_date' => array(
          'formatRule' => array(
              'rule' => array('validDateFormat'),
              'allowEmpty' => false,
              'message' => 'Enter a valid Start date (mm/dd/yyyy)'
          ),
          'dateRestrictionRule' => array(
              'rule' => array('dateBefore', 'valid_end_date'),
              'message' => 'Start date must be before End date'
      )),
      'valid_end_date' => array(
          'rule' => array('validDateFormat'),
          'allowEmpty' => false,
          'message' => 'Enter a valid End date (mm/dd/yyyy)'
      )
  );
   //http://book.cakephp.org/1.3/view/1042/belongsTo


  
}

?>
